package com.example.springboot_code_read.annotationMetadata;

import com.example.springboot_code_read.bean.MyBean;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.stereotype.Component;

import java.util.Map;

public class AnnotationMetadataDemoByReflection {

    public static void main(String[] args) {

        AnnotationMetadata introspect = AnnotationMetadata.introspect(MyBean.class);

        System.out.println("AnnotationMetadata class is " + introspect.getClass());

        boolean isComponent = introspect.hasAnnotation(Component.class.getName());

        System.out.println("has annotation Component : " + isComponent);

        if (isComponent) {

            Map<String, Object> annotationAttributes = introspect.getAnnotationAttributes(Component.class.getName());

            System.out.println("annotation attribute is " + annotationAttributes.get("value"));

        }


    }

}
